from datetime import *
start = date(1900, 1, 1)
end = date(9999, 12, 30)
ans = 0
while start <= end:
    date = start.strftime('%Y%m%d')
    if sum(int(i) for i in date[:4]) == sum(int(i) for i in date[4:]):
        ans += 1
    start += timedelta(days = 1)

print(ans)